www.gusucode.com > 24Beta 虚拟主机版 1.0.0 Beta源码程序 > 24Beta 虚拟主机版 1.0.0 Beta源码程序/24Beta-1.0.0-vhost/protected/modules/admin/controllers/CommentController.php

    <?php

class CommentController extends CController
{
	public function actionList()
	{
	    $pid = (int)$_GET['pid'];
	    $criteria = new CDbCriteria();
	    $criteria->condition = 'post_id = '. $pid;
		$criteria->order = 'id desc';
		$pages = new CPagination(Comment::model()->count($criteria));
		$pages->pageSize = 20;
		$pages->applyLimit($criteria);
	    $comments = Comment::model()->findAll($criteria);
		$this->render('list', array('comments'=>$comments, 'pages'=>$pages));
	}
	
    public function actionDelete()
	{
	    if (app()->request->isAjaxRequest && app()->request->isPostRequest) {
			$cid = isset($_GET['cid']) ? $_GET['cid'] : null;
			if (!empty($cid) && is_numeric($cid)) {
    			$result = Comment::model()->deleteByPk($cid);
    			$data['result'] = $result ? 1 : 0;
    			$data['message'] = '删除' . ($result ? '成功' : '失败');
			} else {
			    $data['result'] = -1;
    			$data['message'] = '参数错误';
			}
		}
		else {
			$data['result'] = -1;
    		$data['message'] = '非法请求';
		}
		echo json_encode($data);
	}

}